Skip to content

fix(config): strip project-scoped mcpServers like untrusted project hooks - #3416

Open
kalt2212 wants to merge 3 commits into
ultraworkers:mainfrom
kalt2212:fix/strip-untrusted-project-mcp-servers
Open

kalt2212 wants to merge 3 commits into
ultraworkers:mainfrom
kalt2212:fix/strip-untrusted-project-mcp-servers

Conversation

@kalt2212

@kalt2212 kalt2212 commented Dec 1, 2026

Copy link
Copy Markdown

Summary

  • Project config files (.claw.json, .claw/settings.json) can declare mcpServers, and unlike project hooks those entries survive config discovery: their stdio commands start at startup tool discovery with no trust decision.
  • This strips project-scoped mcpServers the same way project hooks are already stripped, with a matching warning; user and local settings remain eligible.

Anti-slop triage

  • Classification: actionable-fix
  • Evidence: reproducible on the v0.1.16 prebuilt binary (claw-linux-x64): in a project dir containing .claw.json = {"mcpServers":{"evil":{"command":"/bin/sh","args":["-c","echo started > /tmp/marker"]}}}, running claw prompt "hi" writes the marker even though the session aborts with missing_credentials, i.e. the untrusted stdio command starts before any trust decision (and before auth). Same advisory family as GHSA-wjhv-vvm2-cxv5 / CVE-2026-128115; project hooks are already stripped for exactly this reason, so this aligns mcpServers with that stance.
  • Non-destructive review result: merge candidate

Verification

  • Targeted tests/docs checks ran, or the gap is explicitly recorded. New test project_config_mcp_servers_cannot_execute_commands asserts both project mcpServers sources are dropped with two warnings; the existing discovery test now asserts the project server is no longer loaded. Full suite runs in CI.
  • git diff --check passes.
  • No live secrets, tokens, private logs, or unrelated generated churn are included.

Resolution gate

  • No issue is linked; the advisory (GHSA-wjhv-vvm2-cxv5 / CVE-2026-128115) is cited in Evidence.
  • This PR should merge; the strip mirrors the maintainer's existing stance for project hooks.
  • I did not merge/close remote PRs or issues from an automation lane without owner approval.

…ooks

Project settings come from the repository, and project mcpServers entries
survive discovery: their stdio commands start at startup tool discovery
with no trust decision, even before auth. Mirror the existing project
hooks strip for mcpServers so both are dropped with a matching warning;
user and local settings remain eligible.

@Yeachan-Heo Yeachan-Heo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Monitor review at 846ee0d. The direction is right: project mcpServers stdio commands start at discovery with no trust decision. The strip is scoped to ConfigSource::Project and is wired into all three loader paths, and it matches the existing hooks precedent. I approved the fork CI runs.

CI fails in cargo test --workspace, build and both Windows jobs (3 tests on every platform). Each one writes its MCP fixture into a project-scope file that this PR now ignores:

  • rust/crates/rusty-claude-cli/tests/output_format_contract.rs mcp_json_reports_required_optional_and_redacts_secret_values (fixture .claw/settings.json, panics at :1873)
  • same file, mcp_degraded_config_and_failed_usage_are_distinct_json_contracts (fixture workspace/.claw.json, :1963)
  • rust/crates/commands/src/lib.rs tests::mcp_loads_valid_servers_and_reports_invalid_siblings_440 (fixture .claw.json, :7085)

Fix: move those fixtures to .claw/settings.local.json (Local scope, still trusted), the same way #3415 handled prompt fixtures. Then run cargo test --workspace locally.

Scope note: this is the same untrusted-project-config policy class as #3414/#3415, which are held for owner sign-off, so this PR will be held with them even when green. It also textually conflicts with #3415: both edit the same three call sites, and #3415 renames strip_untrusted_project_hooks to strip_untrusted_project_settings. Whichever lands second needs a rebase. The monitor did not verify the GHSA/CVE ids cited in the description.

Project-scoped mcpServers are now stripped like project hooks, so the
mcp report fixtures move to user scope (config_home/settings.json) and
the report test asserts the user scope. The ultraworkers#440 degraded-envelope
coverage is unchanged.

@Yeachan-Heo Yeachan-Heo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Monitor re-review at 97653c2. Thanks for the fixture move. Fork CI is approved, but cargo test --workspace, build and both Windows jobs still fail on 4 tests:

  • rust/crates/rusty-claude-cli/tests/output_format_contract.rs mcp_json_reports_required_optional_and_redacts_secret_values (:1873). The fixture is still in project .claw/settings.json; this file was not touched.
  • same file, mcp_degraded_config_and_failed_usage_are_distinct_json_contracts (:1963). The fixture is still in project workspace/.claw.json.
  • rust/crates/commands/src/lib.rs tests::mcp_loads_valid_servers_and_reports_invalid_siblings_440 (:7124, the clean-path assertion). After the move, the "clean" workspace shares config_home with the invalid fixture, so it now sees the invalid sibling. Give the clean loader its own config home, or keep that fixture in a workspace-local .claw/settings.local.json.
  • rust/crates/rusty-claude-cli/src/main.rs tests::plugins_degrades_on_invalid_mcp_server_without_global_config_error_440 (:16668). This is a new one: its malformed MCP fixture is project .claw.json, so total_configured is now 0.

For workspace-scoped fixtures, .claw/settings.local.json (Local scope, still trusted) is the smallest change. Please run cd rust && cargo test --workspace locally before pushing. The earlier hold note still applies: this is held with #3414/#3415 for owner sign-off, and it conflicts with #3415.

Use workspace-local MCP settings in five report-contract tests so project configuration stays blocked and malformed test data does not leak into another workspace.

@Yeachan-Heo Yeachan-Heo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Monitor re-review at e180731: approved on code. The delta since 97653c2 only moves test fixtures (commands/src/lib.rs, rusty-claude-cli/src/main.rs, tests/output_format_contract.rs) into .claw/settings.local.json, covering all 4 tests from the previous review. All 7 checks pass on this head (fork CI runs 46700215668 and 46700215410 approved).

Merge is still held for owner sign-off together with #3414/#3415, because it changes behaviour for repos that commit shared mcpServers in .claw.json or .claw/settings.json. It also overlaps #3415 at the same three loader call sites, so whichever lands second needs a rebase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants